
from datetime import datetime
from sqlalchemy import ForeignKey
from sqlalchemy.orm import (
    DeclarativeBase,
    Mapped,
    mapped_column,
    relationship,
)


class Base(DeclarativeBase):
    pass


class Ticket(Base):
    __tablename__ = "tickets"

    id: Mapped[int] = mapped_column(primary_key=True)
    price: Mapped[float] = mapped_column(nullable=True)
    show: Mapped[str | None]
    user: Mapped[str | None]
    sold: Mapped[bool] = mapped_column(default=False)
    
    # create_time: datetime = mapped_column(default_factory=datetime.now, description="创建时间")
    # update_time: datetime = mapped_column(
    #     default_factory=datetime.now,
    #     sa_column_kwargs={"onupdate": datetime.now},
    #     description="更新时间",
    # )
    # is_delete: bool = mapped_column(default=False, description="是否删除", nullable=True)
    
    # details: Mapped["TicketDetails"] = relationship(
    #     back_populates="ticket"
    # )
    # event_id: Mapped[int | None] = mapped_column(
    #     ForeignKey("events.id")
    # )
    # event: Mapped["Event | None"] = relationship(
    #     back_populates="tickets"
    # )
    
    
class TicketDetail(Base):
    __tablename__ = "tickets_detail"

    id: Mapped[int] = mapped_column(primary_key=True)
    price: Mapped[float] = mapped_column(nullable=True)
    show: Mapped[str | None]
    user: Mapped[str | None]
    sold: Mapped[bool] = mapped_column(default=False)
    
    